home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload Trio 2
/
Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO
/
dir37
/
mxmenu.zip
/
NAVYTIME.MNU
< prev
next >
Wrap
Text File
|
1993-06-09
|
6KB
|
275 lines
Comment
==========================================================
This program is used to call the Navy atomic clock and set all
your file servers to the correct time.
You need to set the ComPort to your modem port and the TimeOffset
to match your time zone.
5 - New York
6 - Chicago
7 - Denver
8 - San Francisco
You might have to change the phone number if you to deal with getting an
outside line.
This program will set the time on all servers you are attached to and
have Console Operator status. It will then try to log into all other
servers and set the time.
To log into the other servers and set the time,you will need to create a
dummy user called TIMESYNC and a password of SETTIME. Give this user no
rights but make him a console operator. You can even restrict the login
time to late at night when this program is run. MarxMenu will attempt to
log into all not attached servers under this name and set the time.
MarxMenu will detach as soon as the time is set.
=========================================================
EndComment
var
NumberToDial
TimeOffset
StartTime
StandardIO
;----- Set com port, number, and time offset to match your system.
ComPort = Com2
NumberToDial = '9,1-202-653-0351'
TimeOffSet = 6 ;Offset for Central Standard Time
;===================[ Start of main program ]======================
ComInitPort(1200,8,'N',1) ;1200 baud access only
Writeln
Writeln 'MarxMenu NavyTime'
Writeln 'Copyright 1992-93 by Marc Perkel * All right reserved.'
Writeln
ExitCode = 1 ;errorlevel 1=fail 0=success
StartTime = Now
Writeln '==> Reseting Modem'
ComWrite 'ATZ' CR
WaitFor 'OK'
Writeln
Writeln '==> Sending Modem Init String'
ComWrite 'AT&Q0' CR ;&Q0 puts modem in dumb mode allowing it to
WaitFor 'OK' ;connect faster to atomic clock and save $$$
Writeln
Writeln '==> Calling Naval Atomic Clock'
ComWriteln 'ATD ' NumberToDial
repeat
CallClock
Wait 100
until ComLastLine <> 'BUSY'
ComWatchCD
SetTime(GetTimeString)
SetAllServers
ExitCode = 0 ;success
HangupAndExit
;========================[ Procedures ]=============================
Procedure SetTime (UtcTime)
var T DayOfYear DateSt TimeSt
;- First we pick out the date.
DayOfYear = Value(Mid(UtcTime,7,3))
DateSt = DateString(TimeOf('01-01-' + Str(Year)) + (DayOfYear - 1 * SecondsInDay))
;- Then we pick out the time.
TimeSt = Mid(UtcTime,11,6)
Insert(':',TimeSt,3)
Insert(':',TimeSt,6)
T = TimeOf(DateSt + ' ' + TimeSt)
T = T - (TimeOffset - DaylightSavingsTime * 3600) + 1
Writeln
Writeln
Writeln 'Setting WorkStation Clock ... ' DateString(T) ' ' TimeString(T)
Now = T
NovServerTime = T
SetServerTime(NovDefaultServer)
EndProc
Procedure SetAllServers
var AttachedServers AllServers Server ThisServer
;- We set the clock on all servers are are attached to.
ThisServer = NovDefaultServer
NovAttachedServers(AttachedServers)
SortArray(AttachedServers)
Loop AttachedServers
Server = AttachedServers[LoopIndex]
if Server <> ThisServer
SetServerTime(Server)
endif
EndLoop
NovServers(AllServers)
SortArray(AllServers)
;- We set the clock on all servers are are not attached to.
Loop AllServers
Server = AllServers[LoopIndex]
if PosInSortedList(Server,AttachedServers) = 0 ;not attached
NovLogin(Server + '/TIMESYNC','SETTIME')
if NovResult = 0
SetServerTime(Server)
NovDetach(Server)
else
Writeln 'Login on Server ' Server ' failed!'
endif
endif
EndLoop
EndProc
Procedure SetServerTime (Server)
Write 'Setting Server ' Server ' Clock ... '
NovSetPreferredServer Server
NovServerTime = Now
if NovResult = 0
Writeln DateString ' ' TimeString
else
Writeln 'Failed!'
endif
NovSetPreferredServer ''
EndProc
Procedure GetTimeString
while True
CharLoop
if (length(ComLastLine) = 20) and (Right(ComLastLine,3) = 'UTC')
;- Hangup Modem
ComDTR Off
Return ComLastLine
endif
endwhile
EndProc
Procedure TestAbort
;- ConCDAbort is set to True if Carrier drops.
if ComCDAbort
Writeln '[Carrier Dropped]'
HangupAndExit
endif
;- 2 Minutes or I'm out of here
if Now - StartTime > 120
Writeln
Writeln '==> Timeout Disconnect'
HangupAndExit
endif
;- ESC to Exit
if not KbdReady then Return
LastKey = ReadKey
if LastKey = ESC then HangupAndExit
EndProc
Procedure CharLoop
TestAbort
if ComCharReady
Write ComReadChar
endif
EndProc
Procedure WaitFor (St)
ComLastLine = ''
while ComLastLine <> St
CharLoop
endwhile
Wait 20
EndProc
Procedure HangupAndExit
ComDTR Off
ComWatchCD Off
ComWriteln 'ATZ'
Wait 40
ExitMenu
EndProc
Procedure CallClock
while True
CharLoop
if pos('CONNECT',ComLastLine) > 0
Return
elseif ComCD
Return
elseif ComLastLine = 'BUSY'
Return
elseif ComLastLine = 'NO DIALTONE'
HangupAndExit
elseif ComLastLine = 'NO CARRIER'
HangupAndExit
endif
endwhile
EndProc
Procedure DaylightSavingsTime
var B E
;- First Sunday in April
B = TimeOf('04-01-' + Str(Year))
while DayOfWeekOf(B) <> 0
B = B + SecondsInDay
endwhile
;- Last Sunday in October
E = TimeOf('10-31-' + Str(Year))
while DayOfWeekOf(E) <> 0
E = E - SecondsInDay
endwhile
if Now Within(B,E)
Return 1
else
Return 0
endif
EndProc